/***************************************************************************
Name: JSView
Description: Helps you to view the source code of external js and css files
Author: Ron Beckman
Homepage: http://forum.softwareblaze.com

Copyright (C) 2008  Ron Beckman

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to:

Free Software Foundation, Inc.
51 Franklin Street
Fifth Floor
Boston, MA  02110-1301
USA
***************************************************************************/


var jsviewBehavior = {

	getWin: function(name) {
		return Components.classes["@mozilla.org/appshell/window-mediator;1"].
		getService(Components.interfaces.nsIWindowMediator).
		getMostRecentWindow(name);
	},

	getAppInfo: function() {
		return Components.classes['@mozilla.org/xre/app-info;1'].
		createInstance(Components.interfaces.nsIXULAppInfo);
	},

	init: function() {
		document.getElementById('url').value = window.arguments[0];
	},

	copyLink: function() {
		var brows = this.getAppInfo();
		var win = this.getWin((brows.name!='Songbird') ? 'navigator:browser' : 'Songbird:Main');
		var url = document.getElementById('url').value;
		win.jsview.copyLink(url);
		window.close();
	},

	viewSource: function(type) {
		var brows = this.getAppInfo();
		var win = this.getWin((brows.name!='Songbird') ? 'navigator:browser' : 'Songbird:Main');
		var url = document.getElementById('url').value;
		win.jsview.viewSource(url,type);
		window.close();
	}
};